<?php

class Gold_Orderpreparation_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
{
    /**
     * Manage mass actions
     * 
     * @return unknown
     */
    protected function _prepareMassaction()
    {
    	parent::_prepareMassaction();
    	if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/complete')) {
            $this->getMassactionBlock()->addItem('complete_order', array(
                 'label'=> Mage::helper('sales')->__('Complete'),
                 'url'  => $this->getUrl('Orderpreparation/CarrierTemplate/massComplete'),
            ));
        }    	        

        //raise event to allow other extension to add columns
        Mage::dispatchEvent('salesorder_grid_preparemassaction', array('grid'=>$this));
        
        return $this;
    }
    
    protected function _prepareColumns()
    {    	    	
    	$this->addColumnAfter('shipment_state', array(
            'header'=>Mage::helper('Orderpreparation')->__('Shipment State'),
            'sortable'=>true,
            'index'=>'shipment_state',
            'width' => '80px',
            'type'  => 'text',
        ), 'grand_total');
        
        $this->addColumnAfter('customer_email', array(
            'header'=>Mage::helper('Orderpreparation')->__('Customer Email'),
            'sortable'=>true,
            'index'=>'customer_email',
        ), 'billing_name');
        parent::_prepareColumns();
        $this->removeColumn('shipping_name');        
        return $this;
    }
    
    private function removeColumn($columnId)
    {
    	if ($this->getColumn($columnId))
    	{
    		unset($this->_columns[$columnId]);
    	}
    }

}

?>